package com.nus.fellowmark.common.response;

/**
 * define response code
 *
 * @author Ruoyi Chen
 * @email chenruoyisz@gmail.com
 * @create 2023/2/10
 */
public enum ResponseEnum {

    /**
     * ok
     */
    OK("00000", "ok"),

    /**
     * It is used to directly display the error that prompts the user,
     * and the content is determined by the input content
     */
    SHOW_FAIL("A00001", ""),

    /**
     * The method parameters are not valid,
     * and the content is determined by the input content
     */
    METHOD_ARGUMENT_NOT_VALID("A00002", ""),

    /**
     * Unable to read request parameters
     */
    HTTP_MESSAGE_NOT_READABLE("A00003", "Unable to read request parameters"),

    /**
     * Unauthorized
     */
    UNAUTHORIZED("A00004", "Unauthorized"),

    /**
     * Server unavailable
     */
    EXCEPTION("A00005", "Server unavailable"),

    /**
     * data exception
     */
    DATA_ERROR("A00007", "The data is abnormal, please refresh and try again"),

    /**
     * To access some interfaces, the user need to log in first.
     * but in fact, because the front-end cannot know whether the token has expired,
     * it should return a status code to tell the front-end that the token has expired and clean it up in time
     */
    CLEAN_TOKEN("A00008", "clean token"),

    /**
     * Refresh token has expired
     */
    REFRESH_TOKEN_EXIST("A00009", "refresh token exist"),

    /**
     * incomplete data
     */
    DATA_INCOMPLETE("A00010", "incomplete data"),

    /**
     * 01: Code starting with 01 to represent the user related exception
     */
    USER_NOT_EXIST("A01000", "user does not exist"),

    /**
     * 01: email has already been registered
     */
    EMAIL_DUPLICATE("A01001", "email has already been registered"),

    /**
     * register fail
     */
    REGISTER_FAIL("A01002", "register failed"),
    /**
     * 01: Account not exist
     */
    ACCOUNT_NOT_REGISTER("A01003", "Account not registered"),
    FAIL_TO_REGISTER("A01004", "fail to register"),

    /**
     * 01: Account / password incorrect
     */
    ACCOUNT_PASSWORD_NOT_MATCH("A01003", "Account / password incorrect"),

    /**
     * 01: user is not logged in
     */
    USER_NOT_LOGIN("A01100", "user is not logged in"),

    NOT_PERMIT_ERROR("A01200", "user role not permit"),
    /**
     * 02: Code starting with 02 to represent the assignment related exception
     */
    MSG_NOT_EXIST("A02000", "assignment not exist"),

    /**
     * Arguments not valid
     */
    ARGS_NOT_VALID("B01000", "args not valid"),
    /**
     * constraints violation
     */
    CONSTRAINT_VIOLATION("B01001", "constraints violation"),

    SYS_ERROR("B00000", "SYSTEM ERROR!"),

    NO_SUCH_FILE("C01001", "No such file."),
    FAIL_TO_OUTPUT_FILE("C01002", "Fail to output file.");

    private final String code;

    private final String msg;

    public String value() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    ResponseEnum(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    @Override
    public String toString() {
        return "ResponseEnum{" + "code='" + code + '\'' + ", msg='" + msg + '\'' + "} " + super.toString();
    }

}


